/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.joomtu.smarterlife.config;

import com.joomtu.smarterlife.repositories.UserRepository;
import org.neo4j.graphdb.GraphDatabaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author huguobing
 */
@Component
public class AppStart implements CommandLineRunner {

    @Autowired
    JdbcTemplate jdbcTemplate;

    @Autowired
    private GraphDatabaseService graphDatabaseService;

    @Autowired
    private UserRepository userRepository;

    @Override
    @Transactional
    public void run(String... strings) throws Exception {
//        try (Transaction tx = graphDatabaseService.beginTx()) {
//            Node zhangsan = graphDatabaseService.createNode();
//            zhangsan.setProperty("name", "张三1");
//
//            Node lisi = graphDatabaseService.createNode();
//            lisi.setProperty("name", "李四1");
//
//            Node zhang = graphDatabaseService.getNodeById(zhangsan.getId());
//            Node li = graphDatabaseService.getNodeById(lisi.getId());
//
//            Relationship rel = zhang.createRelationshipTo(li, RelationshipTypes.friend);
//            rel.setProperty("level", "best");
//
//            System.out.println(zhang);
//            System.out.println(li);
//            System.out.println(rel);
//            tx.success();
//        }
//
//        jdbcTemplate.execute("DROP TABLE user");

    }
}
